const e = require('express');
const mongoose = require('mongoose');

// 定义用户数据的 Schema（结构 + 校验）
const competitionSchema = new mongoose.Schema({
  //标题，主题，描述，起始时间，状态进程，创建人，封面，发布平台，奖金，参赛要求
    title: { 
    type: String, 
    required:true,
    unique: true
  },
  theme: {
    type: String, 
    default:''
  },
  description: {    
    type: String, 
    default:''
  },
    startDate:{
    type: String,
    required:true
  },
    endDate:{
    type: String,
    required:true
  },
    status:{
    type: String,
    enum: ['未开始', '进行中', '已结束'],
    default: '未开始'
  },
  creatorId:{ type:mongoose.Schema.Types.ObjectId,ref: 'Admin', required: true },
  cover: { 
    type: String, 
    default:''
  },
  platform:{type:String},
  awards:{type:String},
  rules:{type:String},
});

// 创建并导出 Model（对应 MongoDB 的 "competitions" 集合）
const Competition = mongoose.model('Competition', competitionSchema);

module.exports = Competition;